﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"                    
                    xmlns:sys="clr-namespace:System;assembly=mscorlib">


    
    <Style x:Key="WindowTabControl" TargetType="{x:Type TabControl}">
        <Setter Property="Background" Value="{StaticResource PanelBackgroundBrush}"/>
        <Setter Property="Padding" Value="0"/>                
        <Setter Property="BorderThickness" Value="0"/>                
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="TabItem">                    
                    <Setter Property="Foreground" Value="Black"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate  TargetType="{x:Type TabItem}">
                                <Grid Height="25">
                                    <ContentPresenter x:Name="content" ContentSource="Header" Margin="5,0,15,0" Cursor="Hand">
                                        <ContentPresenter.Resources>
                                            <Style TargetType="{x:Type TextBlock}">
                                                <Setter Property="Foreground" Value="{StaticResource TabItemBrush}"/>
                                                <Setter Property="FontSize" Value="{StaticResource NormalFontSize}"/>
                                            </Style>
                                        </ContentPresenter.Resources>
                                        <ContentPresenter.Style>
                                            <Style>
                                                <Style.Triggers>                                                    
                                                    <Trigger Property="ContentPresenter.IsMouseOver" Value="True">
                                                        <Setter Property="ContentPresenter.Effect">
                                                            <Setter.Value>
                                                                <DropShadowEffect ShadowDepth="0" BlurRadius="10" Color="{StaticResource Green0Color}" />
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Trigger>
                                                </Style.Triggers>
                                            </Style>
                                        </ContentPresenter.Style>
                                    </ContentPresenter>
                                    <Path 
                                        x:Name="arrow"
                                        Visibility="Collapsed" Margin="0,0,15,0"
                                        Fill="{StaticResource ToolBarBorderBrush}" Data="M 0 5 L 8 0 L 16 5 Z" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
                                </Grid>
                                    

                                <ControlTemplate.Triggers>                                   
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter TargetName="content" Property="ContentPresenter.Effect" Value="{x:Null}"/>
                                        <Setter TargetName="arrow" Property="Path.Visibility" Value="Visible"/>
                                    </Trigger>

                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>                    
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource TabSelectedItemBrush}"/>
                        </Trigger>
                        <!--<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=Items.Count}" Value="1">
                            <Setter Property="Visibility" Value="Hidden"/>
                        </DataTrigger>-->
                    </Style.Triggers>
                </Style>
            </Setter.Value>
        </Setter>
        <!--<Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>                    
                    <ContentPresenter Content="{Binding .}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>-->
    </Style>

    <Style x:Key="DockPanelTabControl"  TargetType="{x:Type TabControl}">
        <Setter Property="Background" Value="{StaticResource DockPanelLeftBackground}"/>        
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Padding" Value="0"/>
       
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="TabItem">
                    <Setter Property="Content" Value="{Binding View}"/>
                        
                    <Setter Property="Header" Value="{Binding PanelName}"/>                    
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type TabItem}">
                                <ControlTemplate.Resources>
                                    <Style TargetType="{x:Type ToggleButton}">                                        
                                        <Setter Property="IsTabStop" Value="False"/>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                    <Border x:Name="border" Padding="5,3,5,5" Margin="0,0,0,0"  CornerRadius="0" Cursor="Hand">
                                                        <Grid>
                                                            <Image Source="{Binding ImageUrl}" Width="16" Height="16" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                            <ContentPresenter x:Name="contentPresenter" ContentSource="Content" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="20,0,0,0">
                                                                <ContentPresenter.Resources>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontSize" Value="{StaticResource BigFontSize}"/>
                                                                    </Style>
                                                                </ContentPresenter.Resources>
                                                            </ContentPresenter>
                                                        </Grid>
                                                        
                                                        <Border.Style>
                                                            <Style TargetType="{x:Type Border}" BasedOn="{StaticResource MouseOverListBorder}">                                                               
                                                                <Style.Triggers>
                                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=DataContext.PanelPlacement}" Value="DockPanelLeft">
                                                                        <Setter Property="Border.LayoutTransform">
                                                                            <Setter.Value>
                                                                                <RotateTransform Angle="90" />
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                    </DataTrigger>
                                                                    
                                                                </Style.Triggers>
                                                            </Style>
                                                        </Border.Style>
                                                    </Border>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsChecked" Value="True">
                                                            <Setter TargetName="contentPresenter" Property="TextBlock.Foreground"  Value="{StaticResource DockPanelSelectedTabItemForeground}"/>
                                                        </Trigger>
                                                        <Trigger Property="IsChecked" Value="False">
                                                            <Setter TargetName="contentPresenter" Property="TextBlock.Foreground"  Value="{StaticResource DockPanelTabItemForeground}"/>
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </ControlTemplate.Resources>
                                
                                <ToggleButton                                                             
                                    IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=IsSelected}"
                                    Content="{TemplateBinding Header}"/>                                     
                                
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border Margin="0,0,0,0" CornerRadius="0,0,0,0" Padding="0,0,0,0" BorderThickness="0,0,1,0" BorderBrush="LightGray" Background="White">
                        
                            <ContentPresenter Content="{Binding}" >
                                <ContentPresenter.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <Trigger Property="ContentPresenter.IsEnabled" Value="False">
                                                <Setter Property="ContentPresenter.Visibility" Value="Collapsed"/>
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </ContentPresenter.Style>
                            </ContentPresenter>
                        
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsDockPanelsEnabled}" Value="False">                
             
                <Setter Property="TabControl.IsEnabled" Value="False"/>
            </DataTrigger>
            <Trigger Property="HasItems" Value="False">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Trigger>                 
        </Style.Triggers>
    </Style>


</ResourceDictionary>